
  import rotate from '@/assets/js/rotate'
function InitViewer(div){
          // 初始化Cesium
          var url ="/map/Tiles_world/{z}/{x}/{y}.png";
          var lay_url="http://{s}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}.png"; // 基础图层
          var viewer = new Cesium.Viewer(div, {
            shouldAnimate: false,
            selectionIndicator: false,
            infoBox: false,
            homeButton: false,
            timeline: false, //是否显示时间线控件
            animation: false, //是否显示动画控件
            navigationHelpButton: false,
            sceneModePicker: false,
            baseLayerPicker: false,
            geocoder:false,
            // imageryProvider:new Cesium.UrlTemplateImageryProvider({url:url,maximumLevel:7})
            imageryProvider: new Cesium.TileMapServiceImageryProvider({
              url: "map/NaturalEarthII",
            }),
          });
          // viewer.scene.globe.show = false;
          // //设置图层
          // var PI=3.1415;
          // var rec =new Cesium.Rectangle(120.384*PI/180, 36.3*PI/180, 120.519*PI/180, 36.34*PI/180)
          var layers =viewer.imageryLayers;
          // var chengyang =layers.addImageryProvider(new Cesium.UrlTemplateImageryProvider({url:"/map/Tiles_chengyang/{z}/{x}/{y}.png",maximumLevel:14,rectangle:rec}))
          //图层亮度和光照效果
          // var layer1 =layers.get(1)
          // layer1.brightness =0.5;
          var layer0 =layers.get(0);
          layer0.brightness =0.2;
          var customColorLight = new Cesium.DirectionalLight({
            direction: new Cesium.Cartesian3(
              1,
              0,
              0
            ),
            color: Cesium.Color.fromCssColorString("#ffffff"),
          });
          viewer.scene.light =customColorLight;

          // 清楚系统默认的鼠标左键事件
            viewer.screenSpaceEventHandler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK);
            viewer.scene.debugShowFramesPerSecond=true;
          var scene =viewer.scene;
          var camera =scene.camera;
          
          //***配置相关***/
          viewer._cesiumWidget._creditContainer.style.display = "none"; // 隐藏版权信息
          viewer.resolutionScale = window.devicePixelRatio; // 调整分辨率
          // 是否开启抗锯齿
          scene.fxaa = true;
          scene.postProcessStages.fxaa.enabled = true;
          // viewer.scene.globe.depthTestAgainstTerrain = true;
            

            			/**
			 * 设置后当相机高度达到设置的最大和最小高度时将不再放大和缩小
			 */
		viewer.scene.screenSpaceCameraController.minimumZoomDistance = 10;//相机的高度的最小值
		viewer.scene.screenSpaceCameraController.maximumZoomDistance = 2000;  //相机高度的最大值
		viewer.scene.screenSpaceCameraController._minimumZoomRate = 30; // 设置相机缩小时的速率
		viewer.scene.screenSpaceCameraController._maximumZoomRate=5906376272    //设置相机放大时的速率
          return viewer;
}

export default InitViewer;